package com.example.home.adapter.provider

import androidx.databinding.DataBindingUtil
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.entity.BaseEntity
import com.example.home.R
import com.example.home.adapter.DiscoverItemType
import com.example.home.databinding.ItemHomeTopBannerItemViewBinding
import com.example.home.entity.viewdata.TopBannerViewData

class TopBannerProvider : BaseItemProvider<BaseEntity>() {
    override val itemViewType: Int  = DiscoverItemType.TOP_BANNER_VIEW
    override val layoutId: Int = R.layout.item_home_top_banner_item_view

    override fun onViewHolderCreated(viewHolder: BaseViewHolder, viewType: Int) {
        DataBindingUtil.bind<ItemHomeTopBannerItemViewBinding>(viewHolder.itemView)
    }

    override fun convert(helper: BaseViewHolder, item: BaseEntity) {
        var dataBinding =helper.getBinding<ItemHomeTopBannerItemViewBinding>()

        if (item!= null && dataBinding!= null){
            var entity =item as TopBannerViewData
            dataBinding.viewData=entity
            dataBinding.executePendingBindings()
        }
    }
}